package com.xhui.controller.exception;

import com.xhui.controller.dto.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;
import java.util.ArrayList;

/**
 * 作为springmvc的异常处理器
 *
 * @author XHui
 * @date 2022/12/27 01:22:49
 * Version: 1.0.0
 * Description: describe the function of this class in one sentence
 */
//@ControllerAdvice
@RestControllerAdvice
public class ProjectExceptionAdvice {

    //扫描所有的异常信息
    @ExceptionHandler
    public AjaxResult Exception(Exception ex){
        //记录日志
        //通知运维
        //通知开发
        ex.printStackTrace(); //打印堆栈追踪
        return new AjaxResult(false, "服务器故障，请稍后再试！");
    }
}
